#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Algorithm特定的Side-Channel AttackModule
针对Not同密码Algorithm的专门化Attack实现
（简化版，用于STM32固件Analyze）
"""

from .base_algorithm_attack import AlgorithmSpecificAttack, AlgorithmSpecificResult
from .aes.aes_attacks import AESSpecificAttacks

# Try导入其他Algorithm（Optional，RequirecryptoModuleSupport）
ALGORITHM_ATTACKS = {'aes': AESSpecificAttacks}
__all__ = ['AlgorithmSpecificAttack', 'AlgorithmSpecificResult', 'AESSpecificAttacks']

try:
    from .sm4.sm4_attacks import SM4SpecificAttacks
    ALGORITHM_ATTACKS['sm4'] = SM4SpecificAttacks
    __all__.append('SM4SpecificAttacks')
except ImportError:
    pass

try:
    from .sm2.sm2_attacks import SM2SpecificAttacks
    ALGORITHM_ATTACKS['sm2'] = SM2SpecificAttacks
    __all__.append('SM2SpecificAttacks')
except ImportError:
    pass

try:
    from .rsa.rsa_attacks import RSASpecificAttacks
    ALGORITHM_ATTACKS['rsa'] = RSASpecificAttacks
    __all__.append('RSASpecificAttacks')
except ImportError:
    pass

try:
    from .ecc.ecc_attacks import ECCSpecificAttacks
    ALGORITHM_ATTACKS['ecc'] = ECCSpecificAttacks
    __all__.append('ECCSpecificAttacks')
except ImportError:
    pass

try:
    from .dilithium.dilithium_attacks import DilithiumSpecificAttacks
    ALGORITHM_ATTACKS['dilithium'] = DilithiumSpecificAttacks
    __all__.append('DilithiumSpecificAttacks')
except ImportError:
    pass

def get_algorithm_attack(algorithm: str):
    """获取指定Algorithm的AttackClass"""
    algorithm = algorithm.lower()
    if algorithm not in ALGORITHM_ATTACKS:
        raise ValueError(f"Unsupported algorithm: {algorithm}")
    return ALGORITHM_ATTACKS[algorithm]
